package com.kele.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author 赵奥林
 * @date 2021年05月29日 16:02
 * @Description  瀑布流图片遍历
 */
@RestController
@RequestMapping("/photo")
public class PhotoController {

    @RequestMapping("/listPhoto")
    public List<String> listPhoto(HttpServletRequest request){
        List<String> list=new ArrayList<String>();
        String path=request.getSession().getServletContext().getRealPath("/");
        File file=new File(path+"/static_resources/waterfallImg");
        File[] files=file.listFiles();
        if (null!=files){
            for (int i=0;i< files.length;i++){
                File file1=files[i];
                String name=file1.getName();
                list.add(name);
            }
            return list;
        }else {
            return null;
        }
    }

}
